package co.za.alacrity.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JLabel;

import co.za.alacrity.obseverpattern.TextFieldListener;



public class TextFields extends JLabel{

	    private int x;      // x position in  row.
	    private int y;      // Y position in column.
	    
	    private boolean changeable=true;
	    
	    /**
	     * Constructs the label and sets row and column positions in sudokuGame.
	     * @param owner 
	     *
	     */
	    public TextFields(int x, int y, final TextFieldListener owner) {
	        super("", CENTER);
	        this.x = x;
	        this.y = y;
	        setPreferredSize(new Dimension(40, 40));
	        setBorder(BorderFactory.createLineBorder(Color.GRAY));
	        setFont(new Font(Font.DIALOG, Font.PLAIN, 20));
	        setOpaque(true);
	        
	        final TextFields self= this;
	        
	        this.addMouseListener(new MouseListener() {
				
				@Override
				public void mouseReleased(MouseEvent arg0) {
					
					
				}
				
				@Override
				public void mousePressed(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				
				@Override
				public void mouseExited(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				
				@Override
				public void mouseEntered(MouseEvent arg0) {
					// TODO Auto-generated method stub
					
					
				}
				
				@Override
				public void mouseClicked(MouseEvent arg0) {
					owner.LabelClicked(self);
				}
			});
	    }

		public void setValue(int v) {
			if (changeable)
			setText(""+(v==0?" ":v));
		}

		public void setBold(boolean b) {
			setFont(new Font("serif", b?Font.BOLD:Font.PLAIN, 18));
			changeable=!b;
		}

		public int getRow() {
			return y;
		}

		public int getCol() {
			return x;
		}

		public void setColor(Color c) {
			super.setBackground(c);
		}

		
	    
	    
	    
	    
	    
	}
	


